[WIP] autoPatchelfHook: search a valid interpreter, or fail#66620
[WIP] autoPatchelfHook: search a valid interpreter, or fail#66620layus wants to merge 7 commits intoNixOS:masterfrom
Conversation
|
Tests finished. It seems that this patch breaks a lot of tools based on autoPatchelfHook. For example |
|
@aszlig Spacechem (openlab-aux/vuizvui#18) needs this to patch correclty the 32bit binary rgb2theora used for solution saves. |
aszlig
left a comment
There was a problem hiding this comment.
Thanks for the pull request :-)
However, besides the comments mentioned, I'm against introducing unnecessary complexity if there is not a really compelling reason to do so. For the Spacechem example you mentioned, can't you just use callPackage_i686 like this, because it seems that the game is 32bit only?
| lib.optional (os == "linux") [ pkgs.glibc pkgs.zlib pkgs.ncurses5 pkgs_i686.glibc pkgs_i686.zlib pkgs_i686.ncurses5 ]; | ||
| patchInstructions = '' | ||
| ${lib.optionalString (os == "linux") '' | ||
| rm -r $packageBaseDir/{i686,aarch64,mipsel,arm}-linux* |
| ) | ||
|
|
||
| echo "searching an '$(getSoArch "$toPatch")' interpreter for $toPatch" >&2 | ||
| for f in "${linkers[@]}"; do |
There was a problem hiding this comment.
| for f in "${linkers[@]}"; do | |
| for interpreter in "${interpreters[@]}"; do |
| patchElfInterpreter() { | ||
| local toPatch=$1 | ||
| local linkers=( \ | ||
| "$NIX_CC/nix-support/dynamic-linker" \ |
There was a problem hiding this comment.
You don't need to use backslashes for continuations here, besides, why have autoPatchelfLinkers and linkers here again?
| gatherLibraries() { | ||
| autoPatchelfLibs+=("$1/lib") | ||
| if [ -f "$1/nix-support/dynamic-linker" ]; then | ||
| autoPatchelfLinkers+=("$1/nix-support/dynamic-linker") |
There was a problem hiding this comment.
| autoPatchelfLinkers+=("$1/nix-support/dynamic-linker") | |
| autoPatchelfLinkers+="$(< "$1/nix-support/dynamic-linker")" |
| autoPatchelfLinkers+=("$1/nix-support/dynamic-linker") | ||
| fi | ||
| if [ -f "$1/nix-support/dynamic-linker-m32" ]; then | ||
| autoPatchelfLinkers+=("$1/nix-support/dynamic-linker-m32") |
There was a problem hiding this comment.
| autoPatchelfLinkers+=("$1/nix-support/dynamic-linker-m32") | |
| autoPatchelfLinkers+="$(< "$1/nix-support/dynamic-linker-m32")" |
| --replace /usr/bin/bitwig-studio $out/bin/bitwig-studio | ||
|
|
||
| # We only support x86_64-linux anyway, | ||
| # and these files cannot be correctly autoPatchelfHooked |
There was a problem hiding this comment.
Why can't they be correctly autoPatchelfHooked?
|
The compelling reason was that I needed it for #65069. Not sure if switching to 32bit would be enough. It seems that the canon capt drivers have both 32 and 64 bits binaries packaged. |
|
I'm curious if you tried the (somewhat simpler) patch in #51588? |
|
Not sure how much more simple it is. I did not test it, but the fact that it seemingly does not introduce issues in other packages either means that it is much better than mine, or was just not tested against nixpkgs. Using |
|
Thank you for your contributions.
|
|
I marked this as stale due to inactivity. → More info |
|
The hook is now python https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/auto-patchelf.py |
Motivation for this change
autoPachelfHookpatches everything with the same interpreter(
$NIX_CC/nix-support/dynamic-linker) even on incompatible binaries.This happens in particular when building with
multiStdenv.See https://discourse.nixos.org/t/binary-still-not-working-even-when-properly-patchelfed/1570/3?u=layus for details.
Things done
sandboxinnix.confon non-NixOS)nix-shell -p nix-review --run "nix-review wip"Notify maintainers
cc @tadfisher